package com.analyse.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.analyse.common.annotation.Log;
import com.analyse.common.core.controller.BaseController;
import com.analyse.common.core.domain.AjaxResult;
import com.analyse.common.enums.BusinessType;
import com.analyse.system.domain.Weibhtml;
import com.analyse.system.service.IWeibhtmlService;
import com.analyse.common.utils.poi.ExcelUtil;
import com.analyse.common.core.page.TableDataInfo;

/**
 * 数据展示Controller
 * 
 * @author analyse
 * @date 2023-05-09
 */
@RestController
@RequestMapping("/system/weibhtml")
public class WeibhtmlController extends BaseController
{
    @Autowired
    private IWeibhtmlService weibhtmlService;

    /**
     * 查询数据展示列表
     */
    @PreAuthorize("@ss.hasPermi('system:weibhtml:list')")
    @GetMapping("/list")
    public TableDataInfo list(Weibhtml weibhtml)
    {
        startPage();
        List<Weibhtml> list = weibhtmlService.selectWeibhtmlList(weibhtml);
        return getDataTable(list);
    }

    /**
     * 导出数据展示列表
     */
    @PreAuthorize("@ss.hasPermi('system:weibhtml:export')")
    @Log(title = "数据展示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Weibhtml weibhtml)
    {
        List<Weibhtml> list = weibhtmlService.selectWeibhtmlList(weibhtml);
        ExcelUtil<Weibhtml> util = new ExcelUtil<Weibhtml>(Weibhtml.class);
        util.exportExcel(response, list, "数据展示数据");
    }

    /**
     * 获取数据展示详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:weibhtml:query')")
    @GetMapping(value = "/{html}")
    public AjaxResult getInfo(@PathVariable("html") String html)
    {
        return success(weibhtmlService.selectWeibhtmlByHtml(html));
    }

    /**
     * 新增数据展示
     */
    @PreAuthorize("@ss.hasPermi('system:weibhtml:add')")
    @Log(title = "数据展示", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Weibhtml weibhtml)
    {
        return toAjax(weibhtmlService.insertWeibhtml(weibhtml));
    }

    /**
     * 修改数据展示
     */
    @PreAuthorize("@ss.hasPermi('system:weibhtml:edit')")
    @Log(title = "数据展示", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Weibhtml weibhtml)
    {
        return toAjax(weibhtmlService.updateWeibhtml(weibhtml));
    }

    /**
     * 删除数据展示
     */
    @PreAuthorize("@ss.hasPermi('system:weibhtml:remove')")
    @Log(title = "数据展示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{htmls}")
    public AjaxResult remove(@PathVariable String[] htmls)
    {
        return toAjax(weibhtmlService.deleteWeibhtmlByHtmls(htmls));
    }
}
